package com.itcast.springboot.Intercepter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 注册自定义拦截器
 */

@Component
public class Mvcconfig implements WebMvcConfigurer {

    //注入自定义拦截器
    @Autowired
    private MyIntercepter myIntercepter;

    //addPahtPatterns  用来定拦截的路径
    ///**:代表拦截所有的请求   拦截某一个功能模块使用/user/*

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(myIntercepter).addPathPatterns("/**");
    }

}
